#include <QApplication>
#include <QPushButton>
#include <QMessageBox>
#include <QFrame>
#include <QLabel>

#include <opencv2/opencv.hpp>
#include <thread>

#include "ElaApplication.h"
#include "ElaPushButton.h"
#include "ElaWindow.h"
#include "ElaAppBar.h"

#include "mainwindow.h"
#include "T_Graphics.h"

// TODO: change to ela widgets, not origin qt
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    ElaApplication::getInstance()->init();

    // TODO: check how to log in
    MainWindow w;
    w.show();
    
    QWidget *mask = new QWidget(&w);
    mask->setStyleSheet("background-color: rgba(0,0,0,200);");
    mask->setWindowFlags(mask->windowFlags() | Qt::WindowStaysOnTopHint);
    mask->resize(9999,9999);
    mask->show();

    int *flag = &(w._loginpage->flag);
    w._loginpage->show();

    QObject::connect(w._loginpage,&LoginPage::flagChangedSignal,&w,[&](){
     if(*flag == 0)
     {
        w.setUserInfoCardTitle("请登录");
        w.setUserInfoCardSubTitle("登录以使用更多功能");
         mask->show();
         w._loginpage->show();
     }
     else
     {
        w.setUserInfoCardTitle(w._loginpage->Name);
        w.setUserInfoCardSubTitle(w._loginpage->Acc);
         mask->close();
     }
     });


    return a.exec();

}
